package com.test.test1;

import com.test.mapper.CategoryMapper;
import com.test.pojo.Category_;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jws.WebParam;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@MapperScan("com.test.mapper")
public class HelloController {
    @Autowired
    private CategoryMapper categoryMapper;

    //@WebParam 解析URL传值或者POST传值 ok是KEY value中的KEy
    @RequestMapping("/h")
    public  String hello(@WebParam String ok , @WebParam String id ){
        System.out.println(ok);
        System.out.println(id);
        return "hello world" ;
    }


    @RequestMapping("/list")
    public String list(){
        List<Category_> cs = categoryMapper.findAll() ;
        for ( Category_ R :cs ) {
            System.out.println( R.getId());
        }
        return "list ok" ;
    }

    @RequestMapping("/json")
    public Map<String ,Object> json(){
        Map< String , Object> m = new HashMap<>() ;
        m.put("a" ,1);
        m.put("b",2);
        return m ;
    }
}
